﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Globalization;

namespace inohigo
{
	public enum TokenType
	{
		NUMBER,		// 2
		ADD_OP,		// +
		MINUS_OP,	// -
		DIV_OP,		// /
		MUL_OP,		// *
		SPACE,		// ' '
		UNKNOWN,
		IF,
		ELSE,
		THEN,
		//		SEPARATOR,
		LETTER
	}

	public class Token
	{
		public Token() { }

		public TokenType TokenType { get; set; }
		public Char Value { get; set; }

		public static TokenType GetTokenType( char input )
		{
			if( Char.IsNumber( input ) )
			{
				return TokenType.NUMBER;
			}
			else if( Char.IsSeparator( input ) )
			{
				var category = CharUnicodeInfo.GetUnicodeCategory( input );
				if( category == UnicodeCategory.SpaceSeparator ) { return TokenType.SPACE; }
				else { return TokenType.UNKNOWN; }
			}
			else if( Char.IsLetter( input ) ) // Unicode Character
			{
				return TokenType.LETTER;
			}
			else if( Char.IsSymbol( input ) )
			{
				if( input == '+' ) { return TokenType.ADD_OP; }
				else if( input == '-' ) { return TokenType.MINUS_OP; }
				else if( input == '/' ) { return TokenType.DIV_OP; }
				else if( input == '*' ) { return TokenType.MUL_OP; }
				else { return TokenType.UNKNOWN; }
			}
			else
			{
				return TokenType.UNKNOWN;
			}
		}
	}

}
